package com.situ.day6;

import com.situ.day5.Person;

//JavaBean  实体类
public class Student extends Person {
    //私有的属性只能在类的内部访问
    private String className;

    //默认无参构造方法
    //构造方法：没有返回值，方法名和类名一致
    public Student() {
        super();// new Person();
        //System.out.println("Student.Student");
    }

    public Student(int id, String name, int age, String gender, String className) {
        //super();
        super(id, name, age, gender);// new Person(id,name,age,gender);
        this.className = className;
    }

    public void study() {
        System.out.println("Student.study");
    }

    @Override
    public void show() {
        //super.show();
        System.out.println("Student.show");

    }

    //public所有地方都可以访问
    /*public void setAge(int age) {
        //The value age assigned to 'age' is never used
        //Variable 'age' is assigned to itself
        //就近原则
        //age = age;
        //this:当前类的对象
        //student.setAge(23);
        if (age >=1 && age <= 125) {
            this.age = age;
        }
    }*/

    @Override
    public String toString() {
        return "Student{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", gender='" + gender + '\'' +
                ", className='" + className + '\'' +
                '}';
    }
}
